package com.insurance.security;

import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Style
 * @version 1.0
 * @date 2020/12/11
 **/
//@Component
public class ValidateCodeFilter extends OncePerRequestFilter {

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        String validateCode = request.getParameter("validateCode");
        if("1234".equals(validateCode)){
            System.out.println("【验证码校验成功】");
            filterChain.doFilter(request, response);
        }else{
            throw new IOException("验证码输入错误");
        }
    }
}
